<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on March 12, 2009 at 4:01:36 pm</time-stamp>


<class>
<name>SupplierTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>supplier i1 i2 i3 i4 i5 inventory itemList i6 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.SupplierTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.SupplierTest</class-id>
<body>Tester for the supplier class

Instance Variables:
	i1	&lt;Item&gt; a test item instance
	i2	&lt;Item&gt;	a test item instance
	i3	&lt;Item&gt;	a test item instance
	i4	&lt;Item&gt;	a test item instance
	i5	&lt;Item&gt;	a test item instance
	inventory	&lt;Inventory&gt;	an instance of the inventory to seed the supplier with
	supplier       &lt;Supplier&gt; an instance of the suppier to test.
</body>
</comment>

<methods>
<class-id>SupplyChain.SupplierTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="addAllItems">addAllItems
   "utility method to add all the items to the inventory"
   inventory addItem: i1.
   inventory addItem: i2.
   inventory addItem: i3.
   inventory addItem: i4.
   inventory addItem: i5.

</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	supplier:= nil.
	inventory := nil.
	itemList := OrderedCollection new.

	^self</body>

<body package="SupplyChain" selector="setUpPrices">setUpPrices
   " utility method to add all items and set the internal data for tests"
   self addAllItems.
   i1 buyPrice: 3.
   i1 sellPrice: 7.
   i1 quantity: 8.
   i1 reorderPoint: 9.
   i1 lotNumber: 12.
   i2 buyPrice: 22.
   i2 sellPrice: 36.
   i2 quantity: 7.
   i2 reorderPoint: 6.
   i2 lotNumber: 5.
   i3 buyPrice: 18.
   i3 sellPrice: 40.
   i3 quantity: 3.
   i3 reorderPoint: 3.
   i3 lotNumber: 2.
   i4 buyPrice: 19.
   i4 sellPrice: 36.
   i4 quantity: 6.
   i4 reorderPoint: 7.
   i4 lotNumber: 54.
   i5 buyPrice: 24.
   i5 sellPrice: 36.
   i5 quantity: 12.
   i5 reorderPoint: 10.
   i5 lotNumber: 32.
   i6 lotNumber: 14.
   i6 buyPrice: 32.
   i6 sellPrice: 36.
   i6 quantity: 99.
   i6 reorderPoint: 10.
</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1">i1
	
	^i1</body>

<body package="SupplyChain" selector="i1:">i1: anItem
	
	i1 := anItem.
	^self</body>

<body package="SupplyChain" selector="i2">i2
	
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anItem
	
	i2 := anItem.
	^self</body>

<body package="SupplyChain" selector="i3">i3
	
	^i3</body>

<body package="SupplyChain" selector="i3:">i3: anItem
	
	i3 := anItem.
	^self</body>

<body package="SupplyChain" selector="i4">i4
	
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anItem
	
	i4 := anItem.
	^self</body>

<body package="SupplyChain" selector="i5">i5
	
	^i5</body>

<body package="SupplyChain" selector="i5:">i5: anItem
	
	i5 := anItem.
	^self</body>

<body package="SupplyChain" selector="i6">i6

	^i6</body>

<body package="SupplyChain" selector="i6:">i6: anItem
	
	i6 := anItem.
	^self</body>

<body package="SupplyChain" selector="inventory">inventory

	^inventory</body>

<body package="SupplyChain" selector="inventory:">inventory: anInventory

	inventory := anInventory.
	^self</body>

<body package="SupplyChain" selector="itemList">itemList
	
	^itemList</body>

<body package="SupplyChain" selector="itemList:">itemList: aList
	
	itemList:= aList.
	^self</body>

<body package="SupplyChain" selector="supplier">supplier

	^supplier</body>

<body package="SupplyChain" selector="supplier:">supplier: aSupplier

	supplier:= aSupplier.
	
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="setUp">
setUp
   "Create test objects.  This is called before every individual test"
   inventory := Inventory new.
   supplier:= Supplier new.

   i1 := Item named: 'Video Game' sku:'89X999'.
   i2 := Item named: 'TV' sku: '99Z837'.
   i3 := Item named: 'VCR' sku: '54Y3632'.
   i4 := Item named: 'PC' sku: '01P6373'.
   i5 := Item named: 'Laptop' sku: '11F4732'.
   i6 := Item named: 'DVD' sku: '11F2374'.

   self setUpPrices.
   self addAllItems.

   supplier inventory: inventory.</body>

<body package="SupplyChain" selector="testOrderItems">testOrderItems

	| tempInvoice	|

      self setUpPrices.
   	self addAllItems.
	

	itemList add: i1.
      itemList add: i4.


	tempInvoice:= supplier orderItems: itemList.

	

	self assert: tempInvoice itemList size = 2.
      self assert: (tempInvoice itemList includes: i1).
	self assert: (tempInvoice itemList includes: i4).</body>

<body package="SupplyChain" selector="testSellItem">testSellItem

	self assert: (supplier sellItem: i3).
	
	self deny: (supplier sellItem: i6).</body>
</methods>

</st-source>
